package com.aletto.general_store;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

import com.aletto.general_store.configs.EventBusAutoConfig;
import com.aletto.general_store.utils.XHelper;
import com.scwang.smart.refresh.footer.ClassicsFooter;
import com.scwang.smart.refresh.header.ClassicsHeader;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.constant.SpinnerStyle;

import org.consenlabs.tokencore.BuildConfig;
import org.consenlabs.tokencore.wallet.WalletManager;

public class GeneralStoreApplication extends Application {

    static {

        SmartRefreshLayout.setDefaultRefreshInitializer((context, layout) ->
                layout.setReboundDuration(200)
                        .setEnableAutoLoadMore(true)
                        .setDragRate(0.4f)
                        .setEnableOverScrollBounce(true)
                        .setDisableContentWhenLoading(false)
        );

        SmartRefreshLayout.setDefaultRefreshHeaderCreator((context, layout) ->
                new ClassicsHeader(context)
                        .setTextSizeTitle(12)
                        .setEnableLastTime(false)
                        .setDrawableSize(15)
                        .setDrawableMarginRight(6)
                        .setSpinnerStyle(SpinnerStyle.Translate)
                        .setFinishDuration(200));

        SmartRefreshLayout.setDefaultRefreshFooterCreator((context, layout) ->
                new ClassicsFooter(context).setTextSizeTitle(12)
                        .setFinishDuration(500)
                        .setDrawableSize(15)
                        .setDrawableMarginRight(8)
                        .setSpinnerStyle(SpinnerStyle.Translate));
    }

    public static GeneralStoreApplication sInstance;

    @Override
    public void onCreate() {
        super.onCreate();
        sInstance = this;

        new Handler().postDelayed(() -> {
            WalletManager.storage = this::getFilesDir;
            WalletManager.scanWallets();
        }, 200);


        registerActivityLifecycleCallbacks(new EventBusAutoConfig());
        // unregisterActivityLifecycleCallbacks();

    }

}
